track

abstract fun track(@NonNull eventName: String)

Tracks a noteworthy occurrence or user interaction within the application.

This method records an event with the given eventName. The event will typically be associated with the currently active event session (see newEventSession) and may include a duration if previously started with timeEvent for the same eventName.

Tracked events are usually collected and sent to a backend analytics service for monitoring application usage, user behavior, or system performance.

If you need to include additional contextual data with the event, use the track overload.

Parameters

eventName

The non-null, descriptive name of the event to track (e.g., "CONTENT_PLAYED", "USER_LOGIN", "BUTTON_CLICKED"). This name is used to identify and aggregate events in analytics.

See also

For tracking events with custom properties.

For managing event sessions.

For timing the duration of events.

Throws

if eventName is null.

if eventName is empty.


abstract fun track(@NonNull eventName: String, @Nullable properties: Map<String, Any>)

Tracks a noteworthy occurrence or user interaction, including custom contextual data.

This method records an event with the given eventName and associates it with the provided properties map. The event will also typically be associated with the currently active event session (see newEventSession) and may include a duration if previously started with timeEvent for the same eventName (this duration property would be added to the properties map by the system).

Tracked events and their properties are usually collected and sent to a backend analytics service. The properties allow for richer, more detailed analysis of events.

Property Values: The values in the properties map should generally be simple data types that can be easily serialized (e.g., String, Number, Boolean). Complex objects may not be supported or may be converted to strings. Consult your analytics platform's documentation for any restrictions on property types or nesting.

Parameters

eventName

The non-null, descriptive name of the event to track (e.g., "ITEM_PURCHASED", "VIDEO_COMPLETED", "SETTINGS_CHANGED").

properties

A map of custom key-value pairs to associate with this event. Keys should be strings. Values should ideally be simple data types. This map can be null or empty if no additional properties are needed for this specific event. If null, it behaves like track.

See also

For tracking events without custom properties.

For managing event sessions.

For timing the duration of events.

Throws

if eventName is null.

if eventName is empty.